package com.nwork.qingmanhua.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.nwork.qingmanhua.MyConstants;

/**
 * 数据库的操作类
 */
public class DBHelper extends SQLiteOpenHelper {
    private String createAccountBook =
            "create table " + MyConstants.TABLE_ACCOUNT_BOOK +
                    "(_id integer primary key autoincrement," +
                    "bookname text ," +
                    "bookcount integer default(0)," +
                    "ismark integer default(0) ," +
                    "bg_path integer ," +
                    "createtime text default('null') not null )";

    private String insertCountBook = "insert into " + MyConstants.TABLE_ACCOUNT_BOOK
            + "(bookname,ismark) values ('默认账本',1)";


    public DBHelper(Context context) {
        super(context, MyConstants.DB_NAME, null, MyConstants.DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(createAccountBook);
        db.execSQL(insertCountBook);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
